%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/v4/js-reserved-proto"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 8, 9, 38, 39, 10<br />2: PgSelect[7], PgSelect[15], PgSelect[22]<br />3: 12, 18, 24<br />ᐳ: 11, 13, 17, 19<br />4: ConnectionItems[28]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 13<br /><br />ROOT PgSelectSingleᐸprojectᐳ[13]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 19<br /><br />ROOT PgSelectSingleᐸprojectᐳ[19]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 24, 28<br /><br />ROOT Connectionᐸ22ᐳ[24]"):::bucket
    Bucket5("Bucket 5 (listItem)<br /><br />ROOT __Item{5}ᐸ28ᐳ[33]"):::bucket
    Bucket6("Bucket 6 (nullableBoundary)<br />Deps: 34<br /><br />ROOT PgSelectSingle{5}ᐸprojectᐳ[34]"):::bucket
    end
    Bucket0 --> Bucket1 & Bucket2 & Bucket3
    Bucket3 --> Bucket5
    Bucket5 --> Bucket6

    %% plan dependencies
    PgSelect7[["PgSelect[7∈0] ➊<br />ᐸprojectᐳ<br />More deps:<br />- Constantᐸ'DynaTAC'ᐳ[38]"]]:::plan
    Object10{{"Object[10∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Object10 --> PgSelect7
    Access8{{"Access[8∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access8 & Access9 --> Object10
    PgSelect15[["PgSelect[15∈0] ➊<br />ᐸprojectᐳ<br />More deps:<br />- Constantᐸ2ᐳ[39]"]]:::plan
    Object10 --> PgSelect15
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access8
    __Value2 --> Access9
    First11{{"First[11∈0] ➊"}}:::plan
    PgSelectRows12[["PgSelectRows[12∈0] ➊"]]:::plan
    PgSelectRows12 --> First11
    PgSelect7 --> PgSelectRows12
    PgSelectSingle13{{"PgSelectSingle[13∈0] ➊<br />ᐸprojectᐳ"}}:::plan
    First11 --> PgSelectSingle13
    First17{{"First[17∈0] ➊"}}:::plan
    PgSelectRows18[["PgSelectRows[18∈0] ➊"]]:::plan
    PgSelectRows18 --> First17
    PgSelect15 --> PgSelectRows18
    PgSelectSingle19{{"PgSelectSingle[19∈0] ➊<br />ᐸprojectᐳ"}}:::plan
    First17 --> PgSelectSingle19
    PgSelect22[["PgSelect[22∈0] ➊<br />ᐸprojectᐳ"]]:::plan
    Object10 --> PgSelect22
    Connection24[["Connection[24∈0] ➊<br />ᐸ22ᐳ"]]:::plan
    PgSelect22 --> Connection24
    ConnectionItems28[["ConnectionItems[28∈0] ➊"]]:::plan
    Connection24 --> ConnectionItems28
    PgClassExpression26{{"PgClassExpression[26∈1] ➊<br />ᐸ__project__.”brand”ᐳ"}}:::plan
    PgSelectSingle13 --> PgClassExpression26
    PgClassExpression31{{"PgClassExpression[31∈1] ➊<br />ᐸ__project__.”id”ᐳ"}}:::plan
    PgClassExpression26 o--o PgClassExpression31
    PgClassExpression27{{"PgClassExpression[27∈2] ➊<br />ᐸ__project__.”brand”ᐳ"}}:::plan
    PgSelectSingle19 --> PgClassExpression27
    PgClassExpression32{{"PgClassExpression[32∈2] ➊<br />ᐸ__project__.”__proto__”ᐳ"}}:::plan
    PgClassExpression27 o--o PgClassExpression32
    __Item33[/"__Item[33∈5]<br />ᐸ28ᐳ"\]:::itemplan
    ConnectionItems28 ==> __Item33
    PgSelectSingle34{{"PgSelectSingle[34∈5]<br />ᐸprojectᐳ"}}:::plan
    __Item33 --> PgSelectSingle34
    PgClassExpression35{{"PgClassExpression[35∈6]<br />ᐸ__project__.”__proto__”ᐳ"}}:::plan
    PgSelectSingle34 --> PgClassExpression35
    PgClassExpression36{{"PgClassExpression[36∈6]<br />ᐸ__project__.”brand”ᐳ"}}:::plan
    PgClassExpression35 o--o PgClassExpression36
    PgClassExpression37{{"PgClassExpression[37∈6]<br />ᐸ__project__.”id”ᐳ"}}:::plan
    PgClassExpression36 o--o PgClassExpression37

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect7,Access8,Access9,Object10,First11,PgSelectRows12,PgSelectSingle13,PgSelect15,First17,PgSelectRows18,PgSelectSingle19,PgSelect22,Connection24,ConnectionItems28 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,PgClassExpression26,PgClassExpression31 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression27,PgClassExpression32 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3 bucket3
    classDef bucket5 stroke:#7fff00
    class Bucket5,__Item33,PgSelectSingle34 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgClassExpression35,PgClassExpression36,PgClassExpression37 bucket6

